<?php

/**
 * @author Martin Pernica
 * @copyright 2009
 */

$keyword = urldecode($q[2]);
$keyword = html_entity_decode($keyword);
$keyword = htmlspecialchars_decode($keyword);
$keyword = $db->real_escape_string($keyword);

$query = $db->query("SELECT id, title, pretext, text, date FROM {prefix}articles WHERE title LIKE '".$keyword."%' OR title LIKE '".strtolower($keyword)."%'");

if((int)$query->num_rows == 0){
				Text::h2( Lang::getFront('com_search', 'not_found') );
			}else{
   				$seoParser = new SeoUrl();
				Text::h2( Lang::getFront('com_search', 'found', array((int)$query->num_rows)) );
				echo '<ul>';
				while($result = $query->fetch_array()){
					$url = $seoParser->Parse($result['title']);
					echo '<li><a href="{url}index.php?q=content/'.$result['id']. '-' . $seoParser->result .'">'.$result['title'].'</a></li>';
				}
				echo '</ul>';
			}

?>